Fix msvc unreachable code warnings#1841
Open
kramermt wants to merge 1 commit intoericniebler:masterfrom
Open
Conversation
Author
|
@CaseyCarter , any steps I can take to help advance this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1762 and fixes #1814 .
MSVC's
__assume(false)results in4702: unreachable codewarnings when used as as the first expression in a comma-sequenced return statement (as invariant_visit_'sreturn (RANGES_EXPECT(false), 0);.This PR adds a
RANGES_EXPECT_UNREACHABLE_RETURN(RETURN_VALUE)macro to be used in these cases, which expands to solely the__assume(false);in MSVC release builds; otherwise expands to the priorreturn (RANGES_EXPECT(false), RETURN_VALUE);value.note: gcc no longer implements
-Wunreachable-codeand clang can produce unreachable code warnings, but not in the case ofRANGES_ASSUME()'s conditional use of__builtin_unreachable(). Both compilers still require that areturnoperation be present afterRANGES_ASSUME(false)'s invocation of their__builtin_unreachable()intrinsic.